package util;

import android.annotation.SuppressLint;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebSettings.PluginState;
import android.webkit.WebView;
import android.webkit.WebViewClient;


public class WebCommon {
	@SuppressLint("SetJavaScriptEnabled")
	public static void loadData(WebView mWebView, String Url) {
		mWebView.getSettings().setUseWideViewPort(true);
		mWebView.getSettings().setLoadWithOverviewMode(true);
		WebSettings settings = mWebView.getSettings();
		// 设置webview支持缩放
		settings.setSupportZoom(true);
		// 启用内置缩放装置
		settings.setBuiltInZoomControls(true);
		// 启用js脚本
		settings.setJavaScriptEnabled(true);
		settings.setCacheMode(WebSettings.LOAD_DEFAULT);
		// 自动加载图片
		settings.setLoadsImagesAutomatically(true);
		// 设置webview的插件转状态
		settings.setPluginState(PluginState.ON);
		// 设置默认的字符编码
		settings.setDefaultTextEncodingName("utf-8");

		mWebView.setWebChromeClient(new WebChromeClient());
		mWebView.setWebViewClient(new WebViewClient() {
			@Override
			public boolean shouldOverrideUrlLoading(WebView view, String url) {
				view.loadUrl(url);
				return true;
			}
		});
		mWebView.loadUrl(Url);
		
	}
}
